/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.scm.lcm.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import merlion.common.util.Consts;

/**
 *
 * @author Yuwei
 */
@Entity
public class PackingOrder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String packingOrderId;
    private Boolean done;
    private Timestamp packingOrderDate;
    private String status;
    @OneToOne(targetEntity = DeliveryOrder.class, cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
    private DeliveryOrder deliveryOrder;   
    @OneToMany(targetEntity = LogisticItemLine.class, cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
    private List<LogisticItemLine> logisticItemLines;
    
    public PackingOrder(){
        packingOrderId = "";
        deliveryOrder = new DeliveryOrder();
        packingOrderDate = new Timestamp(new Date().getTime());
        //status = Consts.LOGISTIC_ORDER_QUEUING;
    }
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
    
    public Boolean getDone() {
        return done;
    }

    public void setDone(Boolean done) {
        this.done = done;
    }

    public DeliveryOrder getDeliveryOrder() {
        return deliveryOrder;
    }

    public void setDeliveryOrder(DeliveryOrder deliveryOrder) {
        this.deliveryOrder = deliveryOrder;
    }

    public String getPackingOrderId() {
        return packingOrderId;
    }

    public void setPackingOrderId(String packingOrderId) {
        this.packingOrderId = packingOrderId;
    }

    public Timestamp getPackingOrderDate() {
        return packingOrderDate;
    }

    public void setPackingOrderDate(Timestamp packingOrderDate) {
        this.packingOrderDate = packingOrderDate;
    }

    public List<LogisticItemLine> getLogisticItemLines() {
        return logisticItemLines;
    }

    public void setLogisticItemLines(List<LogisticItemLine> logisticItemLines) {
        this.logisticItemLines = logisticItemLines;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof PackingOrder)) {
            return false;
        }
        PackingOrder other = (PackingOrder) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.scm.lcm.entity.PackingOrder[ id=" + id + " ]";
    }
    
}
